﻿<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
	sdcms.checkuserlogin
	dim classid:classid=sdcms.getint(sdcms.fget("classid",0),0)
	dim data
	dim catedata,catename,modeid
	catedata=sdcms.getclassdb(classid)
	if not isarray(catedata) then
		sdcms.echo "&#26639;&#30446;&#19981;&#23384;&#22312;&#25110;&#24050;&#34987;&#21024;&#38500;"
		sdcms.die
	end if
	catename=catedata(1)
	modeid=catedata(10)
	if catedata(31)=0 then
		sdcms.echo "&#26639;&#30446;&#31105;&#27490;&#25237;&#31295;"
		sdcms.die
	end if
	dim theme_publish_add:theme_publish_add=catedata(29)
	dim userdata,userid,loginbase
	userdata=sdcms.userinfo
	userid=userdata(0)
	loginbase=sdcms.base64encode(userdata(1)&userdata(2))
	dim is_lock:is_lock=sdcms.db.dbloadone("allowpostverify","sd_user_group","id="&userdata(4)&"")
	
	sub adddb()
		dim t0,t1,t2,t3,data
		dim u0,u1
		t0=sdcms.enhtml(sdcms.fpost("t0",0))
		t1=sdcms.enhtml(sdcms.fpost("t1",0))
		t2=sdcms.fpost("t2",1)
		t3=sdcms.enhtml(sdcms.fpost("t3",0))
		if sdcms.strlen(t0)=0 then
			sdcms.ajaxjson "&#35270;&#39057;&#21517;&#31216;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.strlen(t1)=0 then
			sdcms.ajaxjson "&#35270;&#39057;&#22320;&#22336;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.strlen(t2)=0 then
			sdcms.ajaxjson "&#35270;&#39057;&#31616;&#20171;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.strlen(t3)=0 then
			sdcms.ajaxjson "&#39564;&#35777;&#30721;&#19981;&#33021;&#20026;&#31354;",0
			exit sub
		end if
		if sdcms.loadsession("imgcode")="" then
			sdcms.ajaxjson "&#31995;&#32479;&#39564;&#35777;&#30721;&#38169;&#35823;&#65292;&#35831;&#28857;&#20987;&#21047;&#26032;",0
			exit sub
		end if
		if sdcms.loadsession("imgcode")<>t3 then
			sdcms.ajaxjson "&#39564;&#35777;&#30721;&#38169;&#35823;",0
			exit sub
		end if
		u0=sdcms.get_intro(t2)
		u1=sdcms.iif(is_lock=0,-1,1)
		dim cid:cid=sdcms.getint(sdcms.fget("id",0),0)
		if cid=0 then
			select case sdcms.user_publish_num
				case "-1"
					sdcms.ajaxjson "&#24744;&#25152;&#22312;&#30340;&#29992;&#25143;&#32452;&#31105;&#27490;&#25237;&#31295;",0:exit sub
				case "0"
					sdcms.ajaxjson "&#24744;&#20170;&#26085;&#30340;&#25237;&#31295;&#25968;&#37327;&#24050;&#29992;&#23436;",0:exit sub
			end select
			data=array(array("title",t0,255),array("hits",0,10),array("islock",u1,0),array("isnice",0,1),array("ontop",0,1),array("iscomment",1,1),array("createdate",now(),50),array("likeid","0",0),array("ispic",0,1),array("lastupdate",now(),50),array("classid",classid,0),array("isurl",0,1),array("comments",0,0),array("adminid",0,0),array("userid",userid,0),array("intro",u0,0),array("point",0,10))
			if sdcms.db.dbnew("sd_content",data,"title='"&t0&"'")=0 then
				sdcms.ajaxjson "&#35270;&#39057;&#21517;&#31216;&#24050;&#23384;&#22312;&#35831;&#25442;&#20010;&#35797;&#35797;",0
				exit sub
			end if
			cid=sdcms.db.insertid("id","sd_content")
			data=array(array("cid",cid,0,0),array("video",t1,255,1),array("content",t2,0,1),array("vtype",sdcms.is_video(t1),0,1))
			sdcms.db.insert "sd_model_video",data
			sdcms.deal_content_url cid,classid
			if u1=1 then sdcms.deal_user_publish_point cid,userid
		else
			data=array(array("title",t0,255,1),array("hits",0,10,0),array("islock",u1,0,0),array("isnice",0,1,0),array("ontop",0,1,0),array("iscomment",1,1,0),array("createdate",now(),50,1),array("likeid","0",0,1),array("ispic",0,1,0),array("lastupdate",now(),50,1),array("classid",classid,0,0),array("isurl",0,1,0),array("comments",0,0,0),array("adminid",0,0,0),array("userid",userid,0,0),array("intro",u0,0,1),array("point",0,10,0))
			dim edata:edata=sdcms.db.dbload(1,"title","sd_content","id="&cid&" and islock<0 and userid="&userid&"","")
			if ubound(edata)>=0 then
				data=array(array("title",t0,255,1),array("intro",u0,0,1))
				sdcms.db.dbupdate "sd_content","id="&cid&"",data
				data=array(array("video",t1,255,1),array("content",t2,0,1,1),array("vtype",sdcms.is_video(t1),0,1))
				sdcms.db.dbupdate "sd_model_video","cid="&cid&"",data
			end if
		end if
		sdcms.ajaxjson "&#25237;&#31295;&#25552;&#20132;&#25104;&#21151;",1
	end sub
	
	dim act:act=lcase(sdcms.fget("act",0))
	select case act
		case "db":adddb
		case else
			dim id:id=sdcms.getint(sdcms.fget("id",0),0)
			if id>0 then
				dim edata:edata=sdcms.db.dbload(1,"title","sd_content","id="&id&" and islock<0 and userid="&userid&"","")
				if ubound(edata)<0 then
					id=0
				else
					dim title,videourl,content
					title=edata(0,0)
					dim cdata:cdata=sdcms.db.dbload(1,"video,content","sd_model_video","cid="&id&"","")
					if ubound(cdata)>=0 then
						videourl=cdata(0,0)
						content=cdata(1,0)
					end if
				end if
			end if
			sdcms.show theme_publish_add,""
	end select
	sdcms.db.dbclose
%>